
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>12.2：平台通道简介 · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://pcdn.flutterchina.club/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://pcdn.flutterchina.club/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="develop_plugin.html" />
    
    
    <link rel="prev" href="develop_package.html" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 8px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .f-links a{
            text-decoration: underline;
            color: dodgerblue !important;
        }

        .f-links a:hover{
            opacity: .8 !important;
        }

        /*.ad {*/
            /*color: white;*/
            /*text-align: center;*/
            /*background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);*/
            /*background-size: cover;*/
            /*cursor: pointer;*/
            /*margin-bottom: 30px;*/
            /*padding: 18px*/
        /*}*/

        /*.ad:hover {*/
            /*opacity: .8;*/
        /*}*/

        .buy-btn {
            text-decoration: none !important;
            padding: 8px 18px;
            border: #268bd2 1px solid !important;
            display: inline-block !important;
            border-radius: 25px;
            color: #268bd2;
            margin-top: 10px;
        }

        .buy-btn:hover {
            transition: all ease 200ms;
            box-shadow: #555 2px 5px 10px;
            background: #eee;
            color: dodgerblue !important;
        }

        .maoyun{
            padding-top: 5px;
        }


    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
<!--<div class="ad ad0"-->
<!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
<!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
<!--</div>-->
<!--<div class="ad ad1"-->
<!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
<!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
<!--</div>-->
<!--</div>-->

<div class="ad"  style="text-align:center; padding-bottom:30px; display: none"><a href="https://item.jd.com/12816296.html" onclick="buy('img')" title='点击购买' target="_blank"><img style="height:250px;box-shadow: #aaa 5px 5px 10px;" src="https://pcdn.flutterchina.club/imgs/book.png"/></a>  <br/> <a class="buy-btn" onclick="buy('btn')" href="https://item.jd.com/12816296.html" title='点击购买' target="_blank"> 购买实体书 </a></div>


<!--<div class="ad"  style="text-align:center; padding-bottom:30px; display: none"><a href="https://item.jd.com/12816296.html" onclick="buy('img')" title='点击购买' target="_blank"><img style="height:250px;box-shadow: #aaa 5px 5px 10px;" src="https://pcdn.flutterchina.club/imgs/book.png"/></a>  <br/> <a class="buy-btn" onclick="buy('img')" href="https://item.jd.com/12816296.html" title='点击购买' target="_blank"> 购买实体书 </a>-->
    <!--<a id="jd" href="https://item.jd.com/12816296.html" onclick="buy('jd')"  style=" display: block; padding: 10px; color: red; text-decoration: underline; ">即日起至4.23日，京东图书每满100减50！ </a>-->
<!--</div>-->


<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../intro.html">
            
                <a href="../intro.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">入门篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    第一章：起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    1.1：移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    1.2：初识Flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    1.3：搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    1.4：Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    第二章：第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../chapter2/first_flutter_app.html">
            
                <a href="../chapter2/first_flutter_app.html">
            
                    
                    2.1：计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../chapter2/flutter_router.html">
            
                <a href="../chapter2/flutter_router.html">
            
                    
                    2.2：路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../chapter2/flutter_package_mgr.html">
            
                <a href="../chapter2/flutter_package_mgr.html">
            
                    
                    2.3：包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../chapter2/flutter_assets_mgr.html">
            
                <a href="../chapter2/flutter_assets_mgr.html">
            
                    
                    2.4：资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../chapter2/flutter_app_debug.html">
            
                <a href="../chapter2/flutter_app_debug.html">
            
                    
                    2.5：调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="../chapter2/thread_model_and_error_report.html">
            
                <a href="../chapter2/thread_model_and_error_report.html">
            
                    
                    2.6：Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    第三章：基础组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    3.1：Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../chapter3/state_manage.html">
            
                <a href="../chapter3/state_manage.html">
            
                    
                    3.2：状态管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    3.3：文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    3.4：按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    3.5：图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    3.6：单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    3.7：输入框和表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../chapter3/progress.html">
            
                <a href="../chapter3/progress.html">
            
                    
                    3.8：进度指示器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    第四章：布局类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../chapter4/intro.html">
            
                <a href="../chapter4/intro.html">
            
                    
                    4.1：布局类组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../chapter4/row_and_column.html">
            
                <a href="../chapter4/row_and_column.html">
            
                    
                    4.2：线性布局（Row、Column）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="../chapter4/flex.html">
            
                <a href="../chapter4/flex.html">
            
                    
                    4.3：弹性布局（Flex）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="../chapter4/wrap_and_flow.html">
            
                <a href="../chapter4/wrap_and_flow.html">
            
                    
                    4.4：流式布局（Wrap、Flow）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.5" data-path="../chapter4/stack.html">
            
                <a href="../chapter4/stack.html">
            
                    
                    4.5：层叠布局（Stack、Positioned）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.6" data-path="../chapter4/alignment.html">
            
                <a href="../chapter4/alignment.html">
            
                    
                    4.6：对齐与相对定位（Align）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    第五章：容器类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    5.1：填充（Padding）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    5.2：尺寸限制类容器（ConstrainedBox等）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    5.3：装饰容器（DecoratedBox）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    5.4：变换（Transform）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    5.5：Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    5.6：Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.7" data-path="../chapter5/clip.html">
            
                <a href="../chapter5/clip.html">
            
                    
                    5.7：剪裁（Clip）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    第六章：可滚动组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.6.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    6.1：可滚动组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    6.2：SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    6.3：ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    6.4：GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    6.5：CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    6.6：滚动监听及控制（ScrollController）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    第七章：功能型组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="../chapter7/willpopscope.html">
            
                <a href="../chapter7/willpopscope.html">
            
                    
                    7.1：导航返回拦截（WillPopScope）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="../chapter7/inherited_widget.html">
            
                <a href="../chapter7/inherited_widget.html">
            
                    
                    7.2：数据共享（InheritedWidget）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.3" data-path="../chapter7/provider.html">
            
                <a href="../chapter7/provider.html">
            
                    
                    7.3： 跨组件状态共享（Provider）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.4" data-path="../chapter7/theme.html">
            
                <a href="../chapter7/theme.html">
            
                    
                    7.4：颜色和主题（Theme）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.5" data-path="../chapter7/futurebuilder_and_streambuilder.html">
            
                <a href="../chapter7/futurebuilder_and_streambuilder.html">
            
                    
                    7.5：异步UI更新（FutureBuilder、StreamBuilder）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.6" data-path="../chapter7/dailog.html">
            
                <a href="../chapter7/dailog.html">
            
                    
                    7.6：对话框详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    第八章：事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    8.1：原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    8.2：手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    8.3：全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    8.4：通知(Notification)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    第九章：动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    9.1：Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    9.2：动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    9.3：自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    9.4：Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    9.5：交织动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../chapter9/animated_switcher.html">
            
                <a href="../chapter9/animated_switcher.html">
            
                    
                    9.6：通用“动画切换”组件（AnimatedSwitcher）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../chapter9/animated_widgets.html">
            
                <a href="../chapter9/animated_widgets.html">
            
                    
                    9.7：动画过渡组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    第十章：自定义组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../chapter10/intro.html">
            
                <a href="../chapter10/intro.html">
            
                    
                    10.1：自定义组件方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../chapter10/combine.html">
            
                <a href="../chapter10/combine.html">
            
                    
                    10.2：组合现有组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../chapter10/turn_box.html">
            
                <a href="../chapter10/turn_box.html">
            
                    
                    10.3：组合实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../chapter10/custom_paint.html">
            
                <a href="../chapter10/custom_paint.html">
            
                    
                    10.4：自绘组件（CustomPaint与Canvas）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../chapter10/gradient_circular_progress_demo.html">
            
                <a href="../chapter10/gradient_circular_progress_demo.html">
            
                    
                    10.5：自绘实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    第十一章：文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../chapter11/file_operation.html">
            
                <a href="../chapter11/file_operation.html">
            
                    
                    11.1：文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../chapter11/http.html">
            
                <a href="../chapter11/http.html">
            
                    
                    11.2：Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../chapter11/dio.html">
            
                <a href="../chapter11/dio.html">
            
                    
                    11.3：Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../chapter11/download_with_chunks.html">
            
                <a href="../chapter11/download_with_chunks.html">
            
                    
                    11.4：实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../chapter11/websocket.html">
            
                <a href="../chapter11/websocket.html">
            
                    
                    11.5：WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../chapter11/socket.html">
            
                <a href="../chapter11/socket.html">
            
                    
                    11.6：使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="../chapter11/json_model.html">
            
                <a href="../chapter11/json_model.html">
            
                    
                    11.7：Json转Dart Model类
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="./">
            
                <a href="./">
            
                    
                    第十二章：包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="develop_package.html">
            
                <a href="develop_package.html">
            
                    
                    12.1：开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.5.2" data-path="platform-channel.html">
            
                <a href="platform-channel.html">
            
                    
                    12.2：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="develop_plugin.html">
            
                <a href="develop_plugin.html">
            
                    
                    12.3：开发Flutter插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="android_implement.html">
            
                <a href="android_implement.html">
            
                    
                    12.4：插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="ios_implement.html">
            
                <a href="ios_implement.html">
            
                    
                    12.5：插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="texture_platformview.html">
            
                <a href="texture_platformview.html">
            
                    
                    12.6：Texture和PlatformView
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    第十三章：国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../chapter13/multi_languages_support.html">
            
                <a href="../chapter13/multi_languages_support.html">
            
                    
                    13.1：让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../chapter13/locallization_implement.html">
            
                <a href="../chapter13/locallization_implement.html">
            
                    
                    13.2：实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../chapter13/intl.html">
            
                <a href="../chapter13/intl.html">
            
                    
                    13.3：使用Intl包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../chapter13/faq.html">
            
                <a href="../chapter13/faq.html">
            
                    
                    13.4：国际化常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    第十四章：Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../chapter14/flutter_ui_system.html">
            
                <a href="../chapter14/flutter_ui_system.html">
            
                    
                    14.1：Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../chapter14/element_buildcontext.html">
            
                <a href="../chapter14/element_buildcontext.html">
            
                    
                    14.2：Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="../chapter14/render_object.html">
            
                <a href="../chapter14/render_object.html">
            
                    
                    14.3：RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.4" data-path="../chapter14/flutter_app_startup.html">
            
                <a href="../chapter14/flutter_app_startup.html">
            
                    
                    14.4：Flutter从启动到显示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="../chapter14/image_and_cache.html">
            
                <a href="../chapter14/image_and_cache.html">
            
                    
                    14.5：Flutter图片加载与缓存
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实例篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    第十五章：一个完整的Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    15.1：应用简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../chapter15/code_structure.html">
            
                <a href="../chapter15/code_structure.html">
            
                    
                    15.2：APP代码结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../chapter15/models.html">
            
                <a href="../chapter15/models.html">
            
                    
                    15.3：Model类定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../chapter15/globals.html">
            
                <a href="../chapter15/globals.html">
            
                    
                    15.4：全局变量及共享状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../chapter15/network.html">
            
                <a href="../chapter15/network.html">
            
                    
                    15.5：网络请求封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../chapter15/entry.html">
            
                <a href="../chapter15/entry.html">
            
                    
                    15.6：App入口及首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../chapter15/login_page.html">
            
                <a href="../chapter15/login_page.html">
            
                    
                    15.7：登录页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../chapter15/language_and_theme_setting.html">
            
                <a href="../chapter15/language_and_theme_setting.html">
            
                    
                    15.8：多语言和多主题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="https://pcdn.flutterchina.club/gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >12.2：平台通道简介</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="122-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;&#xFF1A;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x7B80;&#x4ECB;">12.2 &#x63D2;&#x4EF6;&#x5F00;&#x53D1;&#xFF1A;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x7B80;&#x4ECB;</h1>
<p>&#x201C;&#x5E73;&#x53F0;&#x7279;&#x5B9A;&#x201D;&#x6216;&#x201C;&#x7279;&#x5B9A;&#x5E73;&#x53F0;&#x201D;&#x4E2D;&#x7684;&#x5E73;&#x53F0;&#x6307;&#x7684;&#x5C31;&#x662F;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x7684;&#x5E73;&#x53F0;&#xFF0C;&#x5982;Android&#x6216;IOS&#x3002;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5B9E;&#x9645;&#x4E0A;&#x5305;&#x62EC;&#x539F;&#x751F;&#x4EE3;&#x7801;&#x548C;Flutter&#x4EE3;&#x7801;&#x4E24;&#x90E8;&#x5206;&#x3002;&#x7531;&#x4E8E;Flutter&#x672C;&#x8EAB;&#x53EA;&#x662F;&#x4E00;&#x4E2A;UI&#x7CFB;&#x7EDF;&#xFF0C;&#x5B83;&#x672C;&#x8EAB;&#x662F;&#x65E0;&#x6CD5;&#x63D0;&#x4F9B;&#x4E00;&#x4E9B;&#x7CFB;&#x7EDF;&#x80FD;&#x529B;&#xFF0C;&#x6BD4;&#x5982;&#x4F7F;&#x7528;&#x84DD;&#x7259;&#x3001;&#x76F8;&#x673A;&#x3001;GPS&#x7B49;&#xFF0C;&#x56E0;&#x6B64;&#x8981;&#x5728;Flutter APP&#x4E2D;&#x8C03;&#x7528;&#x8FD9;&#x4E9B;&#x80FD;&#x529B;&#x5C31;&#x5FC5;&#x987B;&#x548C;&#x539F;&#x751F;&#x5E73;&#x53F0;&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x3002;&#x4E3A;&#x6B64;&#xFF0C;Flutter&#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x5E73;&#x53F0;&#x901A;&#x9053;&#xFF08;platform channel&#xFF09;&#xFF0C;&#x7528;&#x4E8E;Flutter&#x548C;&#x539F;&#x751F;&#x5E73;&#x53F0;&#x7684;&#x901A;&#x4FE1;&#x3002;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x6B63;&#x662F;Flutter&#x548C;&#x539F;&#x751F;&#x4E4B;&#x95F4;&#x901A;&#x4FE1;&#x7684;&#x6865;&#x6881;&#xFF0C;&#x5B83;&#x4E5F;&#x662F;Flutter&#x63D2;&#x4EF6;&#x7684;&#x5E95;&#x5C42;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x3002;</p>
<p>Flutter&#x4F7F;&#x7528;&#x4E86;&#x4E00;&#x4E2A;&#x7075;&#x6D3B;&#x7684;&#x7CFB;&#x7EDF;&#xFF0C;&#x5141;&#x8BB8;&#x60A8;&#x8C03;&#x7528;&#x7279;&#x5B9A;&#x5E73;&#x53F0;&#x7684;API&#xFF0C;&#x65E0;&#x8BBA;&#x5728;Android&#x4E0A;&#x7684;Java&#x6216;Kotlin&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x8FD8;&#x662F;iOS&#x4E0A;&#x7684;ObjectiveC&#x6216;Swift&#x4EE3;&#x7801;&#x4E2D;&#x5747;&#x53EF;&#x7528;&#x3002;</p>
<p>Flutter&#x4E0E;&#x539F;&#x751F;&#x4E4B;&#x95F4;&#x7684;&#x901A;&#x4FE1;&#x4F9D;&#x8D56;&#x7075;&#x6D3B;&#x7684;&#x6D88;&#x606F;&#x4F20;&#x9012;&#x65B9;&#x5F0F;&#xFF1A;</p>
<ul>
<li>&#x5E94;&#x7528;&#x7684;Flutter&#x90E8;&#x5206;&#x901A;&#x8FC7;&#x5E73;&#x53F0;&#x901A;&#x9053;&#xFF08;platform channel&#xFF09;&#x5C06;&#x6D88;&#x606F;&#x53D1;&#x9001;&#x5230;&#x5176;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x6240;&#x5728;&#x7684;&#x5BBF;&#x4E3B;&#xFF08;iOS&#x6216;Android&#xFF09;&#x5E94;&#x7528;&#xFF08;&#x539F;&#x751F;&#x5E94;&#x7528;&#xFF09;&#x3002;</li>
<li>&#x5BBF;&#x4E3B;&#x76D1;&#x542C;&#x5E73;&#x53F0;&#x901A;&#x9053;&#xFF0C;&#x5E76;&#x63A5;&#x6536;&#x8BE5;&#x6D88;&#x606F;&#x3002;&#x7136;&#x540E;&#x5B83;&#x4F1A;&#x8C03;&#x7528;&#x8BE5;&#x5E73;&#x53F0;&#x7684;API&#xFF0C;&#x5E76;&#x5C06;&#x54CD;&#x5E94;&#x53D1;&#x9001;&#x56DE;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x5373;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;Flutter&#x90E8;&#x5206;&#x3002;</li>
</ul>
<h3 id="&#x5E73;&#x53F0;&#x901A;&#x9053;">&#x5E73;&#x53F0;&#x901A;&#x9053;</h3>
<p>&#x4F7F;&#x7528;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x5728;Flutter(client)&#x548C;&#x539F;&#x751F;(host)&#x4E4B;&#x95F4;&#x4F20;&#x9012;&#x6D88;&#x606F;&#xFF0C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/12-3.png" alt="&#x5E73;&#x53F0;&#x901A;&#x9053;"></p>
<p>&#x5F53;&#x5728;Flutter&#x4E2D;&#x8C03;&#x7528;&#x539F;&#x751F;&#x65B9;&#x6CD5;&#x65F6;&#xFF0C;&#x8C03;&#x7528;&#x4FE1;&#x606F;&#x901A;&#x8FC7;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x4F20;&#x9012;&#x5230;&#x539F;&#x751F;&#xFF0C;&#x539F;&#x751F;&#x6536;&#x5230;&#x8C03;&#x7528;&#x4FE1;&#x606F;&#x540E;&#x65B9;&#x53EF;&#x6267;&#x884C;&#x6307;&#x5B9A;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5982;&#x9700;&#x8FD4;&#x56DE;&#x6570;&#x636E;&#xFF0C;&#x5219;&#x539F;&#x751F;&#x4F1A;&#x5C06;&#x6570;&#x636E;&#x518D;&#x901A;&#x8FC7;&#x5E73;&#x53F0;&#x901A;&#x9053;&#x4F20;&#x9012;&#x7ED9;Flutter&#x3002;&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x6D88;&#x606F;&#x4F20;&#x9012;&#x662F;&#x5F02;&#x6B65;&#x7684;&#xFF0C;&#x8FD9;&#x786E;&#x4FDD;&#x4E86;&#x7528;&#x6237;&#x754C;&#x9762;&#x5728;&#x6D88;&#x606F;&#x4F20;&#x9012;&#x65F6;&#x4E0D;&#x4F1A;&#x88AB;&#x6302;&#x8D77;&#x3002;</p>
<p>&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;<a href="https://docs.flutter.io/flutter/services/MethodChannel-class.html" target="_blank">MethodChannel  API</a> &#x53EF;&#x4EE5;&#x53D1;&#x9001;&#x4E0E;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x76F8;&#x5BF9;&#x5E94;&#x7684;&#x6D88;&#x606F;&#x3002; &#x5728;&#x5BBF;&#x4E3B;&#x5E73;&#x53F0;&#x4E0A;&#xFF0C;<code>MethodChannel</code> &#x5728;<a href="https://docs.flutter.io/javadoc/io/flutter/plugin/common/MethodChannel.html" target="_blank">Android API</a> &#x548C; <a href="https://docs.flutter.io/objcdoc/Classes/FlutterMethodChannel.html" target="_blank">FlutterMethodChannel iOS API</a>&#x53EF;&#x4EE5;&#x63A5;&#x6536;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x5E76;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;&#x8FD9;&#x4E9B;&#x7C7B;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x6211;&#x4EEC;&#x7528;&#x5F88;&#x5C11;&#x7684;&#x4EE3;&#x7801;&#x5C31;&#x80FD;&#x5F00;&#x53D1;&#x5E73;&#x53F0;&#x63D2;&#x4EF6;&#x3002;</p>
<blockquote>
<p><strong>&#x6CE8;&#x610F;</strong>: &#x5982;&#x679C;&#x9700;&#x8981;&#xFF0C;&#x65B9;&#x6CD5;&#x8C03;&#x7528;(&#x6D88;&#x606F;&#x4F20;&#x9012;)&#x53EF;&#x4EE5;&#x662F;&#x53CD;&#x5411;&#x7684;&#xFF0C;&#x5373;&#x5BBF;&#x4E3B;&#x4F5C;&#x4E3A;&#x5BA2;&#x6237;&#x7AEF;&#x8C03;&#x7528;Dart&#x4E2D;&#x5B9E;&#x73B0;&#x7684;API&#x3002; <a href="https://pub.dartlang.org/packages/quick_actions" target="_blank"><code>quick_actions</code></a>&#x63D2;&#x4EF6;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x4F8B;&#x5B50;&#x3002;</p>
</blockquote>
<h3 id="&#x5E73;&#x53F0;&#x901A;&#x9053;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x652F;&#x6301;">&#x5E73;&#x53F0;&#x901A;&#x9053;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x652F;&#x6301;</h3>
<p>&#x5E73;&#x53F0;&#x901A;&#x9053;&#x4F7F;&#x7528;&#x6807;&#x51C6;&#x6D88;&#x606F;&#x7F16;/&#x89E3;&#x7801;&#x5668;&#x5BF9;&#x6D88;&#x606F;&#x8FDB;&#x884C;&#x7F16;&#x89E3;&#x7801;&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x9AD8;&#x6548;&#x7684;&#x5BF9;&#x6D88;&#x606F;&#x8FDB;&#x884C;&#x4E8C;&#x8FDB;&#x5236;&#x5E8F;&#x5217;&#x5316;&#x4E0E;&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x3002;&#x7531;&#x4E8E;Dart&#x4E0E;&#x539F;&#x751F;&#x5E73;&#x53F0;&#x4E4B;&#x95F4;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x6709;&#x6240;&#x5DEE;&#x5F02;&#xFF0C;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x5217;&#x51FA;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4E4B;&#x95F4;&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x3002;</p>
<table>
<thead>
<tr>
<th>Dart</th>
<th>Android</th>
<th>iOS</th>
</tr>
</thead>
<tbody>
<tr>
<td>null</td>
<td>null</td>
<td>nil (NSNull when nested)</td>
</tr>
<tr>
<td>bool</td>
<td>java.lang.Boolean</td>
<td>NSNumber numberWithBool:</td>
</tr>
<tr>
<td>int</td>
<td>java.lang.Integer</td>
<td>NSNumber numberWithInt:</td>
</tr>
<tr>
<td>int, &#x5982;&#x679C;&#x4E0D;&#x8DB3;32&#x4F4D;</td>
<td>java.lang.Long</td>
<td>NSNumber numberWithLong:</td>
</tr>
<tr>
<td>int, &#x5982;&#x679C;&#x4E0D;&#x8DB3;64&#x4F4D;</td>
<td>java.math.BigInteger</td>
<td>FlutterStandardBigInteger</td>
</tr>
<tr>
<td>double</td>
<td>java.lang.Double</td>
<td>NSNumber numberWithDouble:</td>
</tr>
<tr>
<td>String</td>
<td>java.lang.String</td>
<td>NSString</td>
</tr>
<tr>
<td>Uint8List</td>
<td>byte[]</td>
<td>FlutterStandardTypedData typedDataWithBytes:</td>
</tr>
<tr>
<td>Int32List</td>
<td>int[]</td>
<td>FlutterStandardTypedData typedDataWithInt32:</td>
</tr>
<tr>
<td>Int64List</td>
<td>long[]</td>
<td>FlutterStandardTypedData typedDataWithInt64:</td>
</tr>
<tr>
<td>Float64List</td>
<td>double[]</td>
<td>FlutterStandardTypedData typedDataWithFloat64:</td>
</tr>
<tr>
<td>List</td>
<td>java.util.ArrayList</td>
<td>NSArray</td>
</tr>
<tr>
<td>Map</td>
<td>java.util.HashMap</td>
<td>NSDictionary</td>
</tr>
</tbody>
</table>
<p> &#x5F53;&#x5728;&#x53D1;&#x9001;&#x548C;&#x63A5;&#x6536;&#x503C;&#x65F6;&#xFF0C;&#x8FD9;&#x4E9B;&#x503C;&#x5728;&#x6D88;&#x606F;&#x4E2D;&#x7684;&#x5E8F;&#x5217;&#x5316;&#x548C;&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x4F1A;&#x81EA;&#x52A8;&#x8FDB;&#x884C;&#x3002;</p>
<h3 id="&#x81EA;&#x5B9A;&#x4E49;&#x7F16;&#x89E3;&#x7801;&#x5668;">&#x81EA;&#x5B9A;&#x4E49;&#x7F16;&#x89E3;&#x7801;&#x5668;</h3>
<p>&#x9664;&#x4E86;&#x4E0A;&#x9762;&#x63D0;&#x5230;&#x7684;<code>MethodChannel</code>&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<a href="https://docs.flutter.io/flutter/services/BasicMessageChannel-class.html" target="_blank"><code>BasicMessageChannel</code></a>&#xFF0C;&#x5B83;&#x652F;&#x6301;&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x6D88;&#x606F;&#x7F16;&#x89E3;&#x7801;&#x5668;&#x8FDB;&#x884C;&#x57FA;&#x672C;&#x7684;&#x5F02;&#x6B65;&#x6D88;&#x606F;&#x4F20;&#x9012;&#x3002; &#x6B64;&#x5916;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E13;&#x95E8;&#x7684;<a href="https://docs.flutter.io/flutter/services/BinaryCodec-class.html" target="_blank"><code>BinaryCodec</code></a>&#x3001;<a href="https://docs.flutter.io/flutter/services/StringCodec-class.html" target="_blank"><code>StringCodec</code></a>&#x548C; <a href="https://docs.flutter.io/flutter/services/JSONMessageCodec-class.html" target="_blank"><code>JSONMessageCodec</code></a>&#x7C7B;&#xFF0C;&#x6216;&#x521B;&#x5EFA;&#x81EA;&#x5DF1;&#x7684;&#x7F16;&#x89E3;&#x7801;&#x5668;&#x3002;</p>
<h3 id="&#x5982;&#x4F55;&#x83B7;&#x53D6;&#x5E73;&#x53F0;&#x4FE1;&#x606F;">&#x5982;&#x4F55;&#x83B7;&#x53D6;&#x5E73;&#x53F0;&#x4FE1;&#x606F;</h3>
<p>Flutter &#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x5168;&#x5C40;&#x53D8;&#x91CF;<code>defaultTargetPlatform</code>&#x6765;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5E94;&#x7528;&#x7684;&#x5E73;&#x53F0;&#x4FE1;&#x606F;&#xFF0C;<code>defaultTargetPlatform</code>&#x5B9A;&#x4E49;&#x5728;&quot;platform.dart&quot;&#x4E2D;&#xFF0C;&#x5B83;&#x7684;&#x7C7B;&#x578B;&#x662F;<code>TargetPlatform</code>&#xFF0C;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x679A;&#x4E3E;&#x7C7B;&#xFF0C;&#x5B9A;&#x4E49;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">enum</span> TargetPlatform <span class="token punctuation">{</span>
  android<span class="token punctuation">,</span>
  fuchsia<span class="token punctuation">,</span>
  iOS<span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x76EE;&#x524D;Flutter&#x53EA;&#x652F;&#x6301;&#x8FD9;&#x4E09;&#x4E2A;&#x5E73;&#x53F0;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#x5224;&#x65AD;&#x5E73;&#x53F0;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">if</span><span class="token punctuation">(</span>defaultTargetPlatform<span class="token operator">==</span>TargetPlatform<span class="token punctuation">.</span>android<span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token comment">// &#x662F;&#x5B89;&#x5353;&#x7CFB;&#x7EDF;&#xFF0C;do something</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
</code></pre>
<p>&#x7531;&#x4E8E;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x6709;&#x5B83;&#x4EEC;&#x5404;&#x81EA;&#x7684;&#x4EA4;&#x4E92;&#x89C4;&#x8303;&#xFF0C;Flutter Material&#x5E93;&#x4E2D;&#x7684;&#x4E00;&#x4E9B;&#x7EC4;&#x4EF6;&#x90FD;&#x9488;&#x5BF9;&#x76F8;&#x5E94;&#x7684;&#x5E73;&#x53F0;&#x505A;&#x4E86;&#x4E00;&#x4E9B;&#x9002;&#x914D;&#xFF0C;&#x6BD4;&#x5982;&#x8DEF;&#x7531;&#x7EC4;&#x4EF6;<code>MaterialPageRoute</code>&#xFF0C;&#x5B83;&#x5728;android&#x548C;ios&#x4E2D;&#x4F1A;&#x5E94;&#x7528;&#x5404;&#x81EA;&#x5E73;&#x53F0;&#x89C4;&#x8303;&#x7684;&#x5207;&#x6362;&#x52A8;&#x753B;&#x3002;&#x90A3;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x8BA9;&#x6211;&#x4EEC;&#x7684;APP&#x5728;&#x6240;&#x6709;&#x5E73;&#x53F0;&#x90FD;&#x8868;&#x73B0;&#x4E00;&#x81F4;&#xFF0C;&#x6BD4;&#x5982;&#x5E0C;&#x671B;&#x5728;&#x6240;&#x6709;&#x5E73;&#x53F0;&#x8DEF;&#x7531;&#x5207;&#x6362;&#x52A8;&#x753B;&#x90FD;&#x6309;&#x7167;ios&#x5E73;&#x53F0;&#x4E00;&#x81F4;&#x7684;&#x5DE6;&#x53F3;&#x6ED1;&#x52A8;&#x5207;&#x6362;&#x98CE;&#x683C;&#x8BE5;&#x600E;&#x4E48;&#x505A;&#xFF1F;Flutter&#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x79CD;&#x8986;&#x76D6;&#x9ED8;&#x8BA4;&#x5E73;&#x53F0;&#x7684;&#x673A;&#x5236;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x663E;&#x5F0F;&#x6307;&#x5B9A;<code>debugDefaultTargetPlatformOverride</code>&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x6765;&#x6307;&#x5B9A;&#x5E94;&#x7528;&#x5E73;&#x53F0;&#x3002;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">debugDefaultTargetPlatformOverride<span class="token operator">=</span>TargetPlatform<span class="token punctuation">.</span>iOS<span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>defaultTargetPlatform<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &#x4F1A;&#x8F93;&#x51FA;TargetPlatform.iOS</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x5373;&#x5728;Android&#x4E2D;&#x8FD0;&#x884C;&#x540E;&#xFF0C;Flutter APP&#x5C31;&#x4F1A;&#x8BA4;&#x4E3A;&#x662F;&#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x662F;iOS&#xFF0C;Material&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x6240;&#x6709;&#x7EC4;&#x4EF6;&#x4EA4;&#x4E92;&#x65B9;&#x5F0F;&#x90FD;&#x4F1A;&#x548C;iOS&#x5E73;&#x53F0;&#x5BF9;&#x9F50;&#xFF0C;<code>defaultTargetPlatform</code>&#x7684;&#x503C;&#x4E5F;&#x4F1A;&#x53D8;&#x4E3A;<code>TargetPlatform.iOS</code>&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="develop_package.html" class="navigation navigation-prev " aria-label="Previous page: 12.1：开发package">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="develop_plugin.html" class="navigation navigation-next " aria-label="Next page: 12.3：开发Flutter插件">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"12.2：平台通道简介","level":"3.5.2","depth":2,"next":{"title":"12.3：开发Flutter插件","level":"3.5.3","depth":2,"path":"chapter12/develop_plugin.md","ref":"chapter12/develop_plugin.md","articles":[]},"previous":{"title":"12.1：开发package","level":"3.5.1","depth":2,"path":"chapter12/develop_package.md","ref":"chapter12/develop_package.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://pcdn.flutterchina.club/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"wendux 824783146@qq.com","bookRoot":"https://book.flutterchina.club/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter12/platform-channel.md","mtime":"2019-08-09T07:47:03.129Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-05-05T06:01:05.405Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://pcdn.flutterchina.club/gitbook/gitbook.js"></script>
    <script src="https://pcdn.flutterchina.club/gitbook/theme.js"></script>
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script src="https://pcdn.flutterchina.club/gitbook/pub.js"></script>
</body>

</html>

